<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<style type="text/css">
</style>
</head>
<body>
<p id="description"></p>
<p><a href="https://bugs.webkit.org/show_bug.cgi?id=85343">Bug 85343</a></p>
<div id="test-container">
    <div id="target" style="cursor:default">Mouse idle, change cursor should not fire mousemove event</div>
</div>
<br/>
<div id="console"></div>
<script>
// This appears to be just to accommodate style update (cursor is updated immediately on mouse events).
// TODO(rbyers): replace with updateAfterDisplay or requestAnimationFrame
var CURSOR_UPDATE_DELAY = 50;

description("Test that there is no mousemove event fired when changing cursor.");

if (!window.eventSender) {
    testFailed('This test requires DumpRenderTree');
}

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
    window.jsTestIsAsync = true;
}

// Can't do anything useful here without eventSender
if (window.eventSender) {
    var node = document.getElementById('target');
    debug('TEST CASE: ' + node.textContent);
    eventSender.mouseMoveTo(node.offsetLeft + 3, node.offsetTop + 3);
    debug('Cursor Info: ' + internals.getCurrentCursorInfo());
    node.addEventListener('mousemove', function() {
        testFailed('Mousemove event should not be fired when changing cursor');
        finishJSTest();
    });
    node.style.cursor = 'help';
    setTimeout(function() {
        debug('Cursor Info: ' + internals.getCurrentCursorInfo());
        debug('');
    }, CURSOR_UPDATE_DELAY);

    // Give some time for the change to resolve. Fake mousemove event that caused bug, is using a timer
    setTimeout(function() {
        document.getElementById('test-container').style.display = 'none';
        finishJSTest();
    }, 150);
}

</script>
</body>
</html>
